<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.2">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="上传代码到 github 创建一个新的库上传git initgit add README.mdgit commit -m “first commit”git branch -M maingit remote add origin &amp;#x67;&amp;#x69;&amp;#116;&amp;#x40;&amp;#103;&amp;#x69;&amp;#116;&amp;#x68;&amp;#x75;&amp;#98;&amp;#46;&amp;#x63;&amp;#111;&amp;#109;:sh">
<meta property="og:type" content="article">
<meta property="og:title" content="Git不常用解决方案">
<meta property="og:url" content="http://example.com/2020/04/26/Git%E4%B8%8D%E5%B8%B8%E7%94%A8%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/index.html">
<meta property="og:site_name" content="Shi">
<meta property="og:description" content="上传代码到 github 创建一个新的库上传git initgit add README.mdgit commit -m “first commit”git branch -M maingit remote add origin &amp;#x67;&amp;#x69;&amp;#116;&amp;#x40;&amp;#103;&amp;#x69;&amp;#116;&amp;#x68;&amp;#x75;&amp;#98;&amp;#46;&amp;#x63;&amp;#111;&amp;#109;:sh">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-04-26T05:50:02.000Z">
<meta property="article:modified_time" content="2023-05-24T08:16:54.626Z">
<meta property="article:author" content="Shi">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/2020/04/26/Git%E4%B8%8D%E5%B8%B8%E7%94%A8%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Git不常用解决方案 | Shi</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Shi</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2020/04/26/Git%E4%B8%8D%E5%B8%B8%E7%94%A8%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="Shi">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shi">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Git不常用解决方案
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-04-26 13:50:02" itemprop="dateCreated datePublished" datetime="2020-04-26T13:50:02+08:00">2020-04-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/source/categories/Git/" itemprop="url" rel="index"><span itemprop="name">Git</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="上传代码到-github"><a href="#上传代码到-github" class="headerlink" title="上传代码到 github"></a>上传代码到 github</h1><ul>
<li><p>创建一个新的库上传<br>git init<br>git add README.md<br>git commit -m “first commit”<br>git branch -M main<br>git remote add origin <a href="mailto:&#x67;&#x69;&#116;&#x40;&#103;&#x69;&#116;&#x68;&#x75;&#98;&#46;&#x63;&#111;&#109;">&#x67;&#x69;&#116;&#x40;&#103;&#x69;&#116;&#x68;&#x75;&#98;&#46;&#x63;&#111;&#109;</a>:shijianmei/hotfixMS.git<br>git push -u origin main</p>
</li>
<li><p>上传一个已经存在的库<br>git remote add origin <a href="mailto:&#x67;&#105;&#x74;&#64;&#103;&#x69;&#x74;&#104;&#x75;&#98;&#46;&#99;&#x6f;&#109;">&#x67;&#105;&#x74;&#64;&#103;&#x69;&#x74;&#104;&#x75;&#98;&#46;&#99;&#x6f;&#109;</a>:shijianmei/hotfixMS.git<br>git branch -M main<br>git push -u origin main</p>
</li>
</ul>
<h1 id="rebase和-merge-的区别"><a href="#rebase和-merge-的区别" class="headerlink" title="rebase和 merge 的区别:"></a>rebase和 merge 的区别:</h1><p>git merge 会生成一个新得合并节点，而rebase不会.</p>
<p>如两个分支:test 和 master</p>
<pre><code>  D---E test

 /
</code></pre>
<p>A—B—C—F master</p>
<p>使用merge合并：</p>
<pre><code>  D--------E

 /          \
</code></pre>
<p>A—B—C—F—-G   test, master</p>
<p>而使用rebase则：</p>
<p>A—B—D—E—C’—F’   test, master</p>
<p>使用git pull时默认是merge， 加 –rebase参数使其使用rebase方式</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git pull --rebase   </span><br></pre></td></tr></table></figure>
<h1 id="git如何忽略已经提交的文件"><a href="#git如何忽略已经提交的文件" class="headerlink" title="git如何忽略已经提交的文件"></a>git如何忽略已经提交的文件</h1><ul>
<li><p>首先将要忽略的文件或文件夹添加到 .gitignore 文件中</p>
</li>
<li><p>停止追踪指定文件</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">// 忽略单个文件</span><br><span class="line">git <span class="built_in">rm</span> <span class="literal">-r</span> <span class="literal">--cached</span> [要忽略的文件/文件夹] </span><br><span class="line">// 忽略所有文件</span><br><span class="line">git <span class="built_in">rm</span> <span class="literal">-r</span> <span class="literal">--cached</span> .</span><br></pre></td></tr></table></figure></li>
<li><p>推送到远程仓库</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git add .</span><br><span class="line">git commit -m &quot; commet for commit .....&quot;</span><br><span class="line">git push</span><br></pre></td></tr></table></figure>
<p>然后其他开发人员pull之后, ignore规则就对其生效了.</p>
</li>
</ul>
<h1 id="git怎样删除未监视的文件untracked-files"><a href="#git怎样删除未监视的文件untracked-files" class="headerlink" title="git怎样删除未监视的文件untracked files"></a>git怎样删除未监视的文件untracked files</h1><p>删除 untracked files:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clean -f</span><br></pre></td></tr></table></figure>
<p>连 untracked 的目录也一起删掉</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clean -fd</span><br></pre></td></tr></table></figure>

<h1 id="git上传本地库到远程仓库"><a href="#git上传本地库到远程仓库" class="headerlink" title="git上传本地库到远程仓库"></a>git上传本地库到远程仓库</h1><ol>
<li><p>拉取远程仓库</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">git clone git@gitlab.alibaba-inc.com:CMedia-iOS/YXWAliyunOSSModule.git</span><br><span class="line">cd YXWAliyunOSSModule</span><br><span class="line">touch README.md</span><br><span class="line">git add README.md</span><br><span class="line">git commit -m &quot;add README&quot;</span><br><span class="line">git push -u origin master</span><br></pre></td></tr></table></figure></li>
<li><p>对于已存在的文件夹或仓库</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">cd existing_folder</span><br><span class="line">git init</span><br><span class="line">git remote add origin git@gitlab.alibaba-inc.com:CMedia-iOS/YXWAliyunOSSModule.git</span><br><span class="line">git add .</span><br><span class="line">git commit</span><br><span class="line">git push -u origin master</span><br></pre></td></tr></table></figure>
<h1 id="git-reset-–hard-、git-push-–force之后如何恢复"><a href="#git-reset-–hard-、git-push-–force之后如何恢复" class="headerlink" title="git reset –hard 、git push –force之后如何恢复"></a>git reset –hard 、git push –force之后如何恢复</h1></li>
</ol>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">1.git reflog</span><br><span class="line">2.查看丢失的commit id</span><br><span class="line">3.创建一个新的分支，在新的分支对丢失的commit id执行：</span><br><span class="line">git cherry-pick 901a33f</span><br></pre></td></tr></table></figure>
<h1 id="如何删除历史记录里的大文件"><a href="#如何删除历史记录里的大文件" class="headerlink" title="如何删除历史记录里的大文件"></a>如何删除历史记录里的大文件</h1><p>适用于从一个git项目中，将体积较大的资源彻底从git中删除，包括历史提交记录。</p>
<p>如果仅仅在目录中删除一个文件是不够的，只要在提交记录中有这个文件，那么 .git 中就会有这个文件的信息。</p>
<p>用 filter-branch 可以强制修改提交信息，将某个文件的历史提交痕迹也抹去，就像从来没有过这个文件一样。</p>
<ol>
<li>找出需要删除的大文件<br>先执行</li>
</ol>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git gc --prune=now</span><br></pre></td></tr></table></figure>
<p>通过如下命令找到git中保存的大小排名前5的大文件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git verify-pack -v .git/objects/pack/pack-*.idx | sort -k 3 -g | tail -5</span><br></pre></td></tr></table></figure>
<p>可以得到如下信息:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">b36ba8c5e4749183794705473321ea312b3a409d blob   46486053 11171997 77887787 1 80c1c35362872c8da6e02117a670902efcdce987</span><br><span class="line">8d1dd2ee60e08b0385fc217a25ea33f36119d694 blob   62475792 7355607 206667227</span><br><span class="line">267a27fef686fbdfbd25210fe36c8a224a5c1a10 blob   81598760 24710676 214022834</span><br><span class="line">abe16d4278121f1a3eacdf3a966326bfb581a741 blob   109294368 28516988 98937450</span><br><span class="line">80c1c35362872c8da6e02117a670902efcdce987 blob   195184864 37268015 40619772</span><br></pre></td></tr></table></figure>
<p>最后一条就是最大的文件记录，80c1c35362872c8da6e02117a670902efcdce987 是其id，通过如下命令找到该文件的位置</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git rev-list --objects --all | grep 80c1c35362872c8da6e02117a670902efcdce987</span><br></pre></td></tr></table></figure>
<p>可以得到如下结果</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">80c1c35362872c8da6e02117a670902efcdce987 AWU3dControl/Frameworks/UnityFramework.framework</span><br></pre></td></tr></table></figure>
<p>AWU3dControl/Frameworks/UnityFramework.framework 即为文件的位置，一般情况下这里的文件位置应该为文件夹/文件夹/文件的格式</p>
<ol start="2">
<li><p>重写所有commit</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git filter-branch --tree-filter &quot;rm -f &#123;filepath&#125;&quot; -- --all</span><br></pre></td></tr></table></figure></li>
<li><p>收尾<br>到这里，历史记录中已经没有该文件了。不过运行 filter-branch 产生的日志还是会对该文件有引用，所以还需要运行以下几条命令，把该文件的引用完全删除：</p>
</li>
</ol>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">rm -Rf .git/refs/original</span><br><span class="line">rm -Rf .git/logs/</span><br><span class="line">git gc</span><br><span class="line">git prune</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>push<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git push -f --all</span><br></pre></td></tr></table></figure>
可以通过以下命令查看.git文件夹大小<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">du -sh .git</span><br></pre></td></tr></table></figure>
<h1 id="git-stash-clear之后的恢复"><a href="#git-stash-clear之后的恢复" class="headerlink" title="git stash clear之后的恢复"></a>git stash clear之后的恢复</h1></li>
</ol>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git fsck <span class="literal">--lost-found</span>, 找出刚才删除的提交对象和文件对象, 里面是一个一个的 dangling commit commitId</span><br><span class="line">git show commitId一个一个的查看修改的内容, 找到了我们需要恢复的commitId之后</span><br><span class="line">git stash apply commitId直接恢复就可以了</span><br></pre></td></tr></table></figure>

<h1 id="配置命令的别名"><a href="#配置命令的别名" class="headerlink" title="配置命令的别名"></a>配置命令的别名</h1><ul>
<li>命令行设置 git 的配置 alias<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git config <span class="literal">--global</span> alias.&lt;简化的字符&gt; 原始命令</span><br></pre></td></tr></table></figure>
如: 设置获取状态<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git config <span class="literal">--global</span> alias.st status <span class="comment">#代表输入 git st 就代表 git status</span></span><br></pre></td></tr></table></figure></li>
<li>手动配置 ~/.gitconfig 文件<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">      pl = pull</span><br><span class="line">      st = status</span><br><span class="line">      ci = commit</span><br><span class="line">      co = checkout</span><br><span class="line">      br = branch</span><br><span class="line">      df = diff</span><br><span class="line">      unstage = reset HEAD --</span><br><span class="line">      lg = log --color --graph --pretty=format:&#x27;%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&lt;%an&gt;%Cres    et&#x27; --abbrev-commit</span><br><span class="line">      last = log --color --graph --pretty=format:&#x27;%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&lt;%an&gt;%Cr    eset&#x27; --abbrev-commit -1 HEAD</span><br><span class="line">[core]</span><br><span class="line">  excludesfile = /Users/mac/.gitignore_global</span><br><span class="line">  editor = /usr/local/bin/vim</span><br><span class="line">[push]</span><br><span class="line">      default = simple</span><br><span class="line">[difftool &quot;sourcetree&quot;]</span><br><span class="line">  cmd = opendiff \&quot;$LOCAL\&quot; \&quot;$REMOTE\&quot;</span><br><span class="line">  path =</span><br><span class="line">[mergetool &quot;sourcetree&quot;]</span><br><span class="line">  cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \&quot;$LOCAL\&quot; \&quot;$REMOTE\&quot; -ancestor \&quot;$BASE\&quot; -merge \&quot;$MERGED\&quot;</span><br><span class="line">  trustExitCode = true</span><br></pre></td></tr></table></figure></li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/03/25/Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" rel="prev" title="Git常用命令">
      <i class="fa fa-chevron-left"></i> Git常用命令
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/03/24/CPU%20&%20%E5%86%85%E5%AD%98%E7%9B%91%E6%8E%A7/" rel="next" title="CPU & 内存监控">
      CPU & 内存监控 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%8A%E4%BC%A0%E4%BB%A3%E7%A0%81%E5%88%B0-github"><span class="nav-number">1.</span> <span class="nav-text">上传代码到 github</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#rebase%E5%92%8C-merge-%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="nav-number">2.</span> <span class="nav-text">rebase和 merge 的区别:</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#git%E5%A6%82%E4%BD%95%E5%BF%BD%E7%95%A5%E5%B7%B2%E7%BB%8F%E6%8F%90%E4%BA%A4%E7%9A%84%E6%96%87%E4%BB%B6"><span class="nav-number">3.</span> <span class="nav-text">git如何忽略已经提交的文件</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#git%E6%80%8E%E6%A0%B7%E5%88%A0%E9%99%A4%E6%9C%AA%E7%9B%91%E8%A7%86%E7%9A%84%E6%96%87%E4%BB%B6untracked-files"><span class="nav-number">4.</span> <span class="nav-text">git怎样删除未监视的文件untracked files</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#git%E4%B8%8A%E4%BC%A0%E6%9C%AC%E5%9C%B0%E5%BA%93%E5%88%B0%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93"><span class="nav-number">5.</span> <span class="nav-text">git上传本地库到远程仓库</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#git-reset-%E2%80%93hard-%E3%80%81git-push-%E2%80%93force%E4%B9%8B%E5%90%8E%E5%A6%82%E4%BD%95%E6%81%A2%E5%A4%8D"><span class="nav-number">6.</span> <span class="nav-text">git reset –hard 、git push –force之后如何恢复</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%A6%82%E4%BD%95%E5%88%A0%E9%99%A4%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95%E9%87%8C%E7%9A%84%E5%A4%A7%E6%96%87%E4%BB%B6"><span class="nav-number">7.</span> <span class="nav-text">如何删除历史记录里的大文件</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#git-stash-clear%E4%B9%8B%E5%90%8E%E7%9A%84%E6%81%A2%E5%A4%8D"><span class="nav-number">8.</span> <span class="nav-text">git stash clear之后的恢复</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE%E5%91%BD%E4%BB%A4%E7%9A%84%E5%88%AB%E5%90%8D"><span class="nav-number">9.</span> <span class="nav-text">配置命令的别名</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">Shi</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">9</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">5</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/shijianmei" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;shijianmei" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        <!--

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Shi</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>
-->

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
